﻿using System.Windows;
using System.Windows.Controls;
using IntoMes.Global;
using IntoMes.ViewModels;
using IntoMes.Views;

namespace IntoMes
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        MainWindowViewModel vm => Locator.Instance.MainWindowViwModel;
        public MainWindow()
        {
            InitializeComponent();
        }

        private int treeIndex;
        public int TreeIndex
        {
            get => treeIndex;
            set
            {
                treeIndex = value;
                UserControl control = null;
                switch (value)
                {
                    case 1: control = new StationStatusView(); break;
                    case 2: control = new SparePartsManageView(); break;
                    //case 3: control = new ProductionQueryView(); break;
                    case 3: control = new QueryTab(); break;
                    case 4: break;
                    case 5: break;
                    case 6: break;
                    default: break;
                }
                if (control != null && show != null)
                {
                    show.Children.Clear();
                    show.Children.Add(control);
                }
            }
        }

        private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            TreeIndex = ((sender as TreeView).SelectedItem as TreeViewItem).TabIndex;
        }

        private void Close_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            treeItem1st.IsSelected = true;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            vm.Identity.DateTime = System.DateTime.Now;
            vm.Identity.TrayId = "11";
        }

        private void Mini_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }
    }
}
